<%--
  Created by IntelliJ IDEA.
  User: LikZ
  Date: 2021.9.7
  Time: 上午 9:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--
描述：菜单栏
-->
<div class="container-fluid">
    <div class="col-md-9">
    <span style="margin-left: 600px;font-size: 40px;color: black">Rice·Mall</span>
    <%--</div>
    <div class="col-md-5">--%>

    </div>

    <div class="col-md-3" style="padding-top:20px;text-align: center;color: black">
        <ol class="list-inline">
            <c:if test="${empty user}">
                <li><a href="${pageContext.request.contextPath}/user?methodName=loginUI" class="lv" style="color: black">用户登录</a></li>
                <!--${pageContext.request.contextPath} 通过pageContext域对象获取request bean属性同时通过
                request对象获取contextPath这个bean属性,获取上下文路径
                等价于pageContext.getRequest().getcontextPath()
                -->
                <li><a href="${pageContext.request.contextPath}/user?methodName=registerUI" class="lv" style="color: black">注册</a></li>
                <li><a href="${pageContext.request.contextPath}/jsp/cart.jsp" class="lv" style="color: black">购物车</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/admin_login.jsp" class="lv" style="color: black">管理员登录</a></li>
            </c:if>
            <c:if test="${not empty user}">
                欢迎,${user.username}
                <li><a href="${pageContext.request.contextPath}/order?methodName=getOrderlist&currentPage=1" style="color: black">订单列表</a></li>
                <li><a href="${pageContext.request.contextPath}/jsp/cart.jsp" class="lv" style="color: black">购物车</a></li>
                <li><a href="${pageContext.request.contextPath}/user?methodName=logout" style="color:black">[退出]</a></li>
            </c:if>
        </ol>
    </div>
</div>
<!--
描述：导航条
-->
<div class="container-fluid">
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="${pageContext.request.contextPath}/index">首页</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul id="ul_Id" class="nav navbar-nav">
                    <li class="active"><a href="#">手机数码<span class="sr-only">(current)</span></a></li>
                </ul>
                <form class="navbar-form navbar-right" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>

            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
</div>

<!--导航栏异步请求-->
<script>
    $(function () {
        $.get("${pageContext.request.contextPath}/category?methodName=getcategoryall",function (data) {
            var $ul = $("#ul_Id");
            //Jquery的each(callback):遍历
            $(data).each(function () {
                $ul.append("<li><a href='${pageContext.request.contextPath}/product?methodName=findProductByPage&currentPage=1&cid="+this.cid+"'>"+this.cname+"</a></li>")

            })

        },"json")

    })
</script>
